package game.utils;

import game.action.BaseAction;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropertiesUtils {
	private static Logger log = Logger.getLogger(PropertiesUtils.class);
	
	public static Map<String, String> getMapByAbsPath(String path){
		Map<String, String> data = new HashMap();
		InputStream is = BaseAction.class.getResourceAsStream("/"+path);
		Properties actionMapping = new Properties();
		try {
			actionMapping.load(is);
			is.close();
			
			Iterator iter = actionMapping.keySet().iterator();
			while(iter.hasNext()){
				String key = iter.next().toString();
				String value = actionMapping.getProperty(key);
				data.put(key, value);
			}
		} catch (IOException e) {
			log.error(e);
		}
		return data;
	}
}
